import React, { Component } from "react";
import { connect } from "react-redux";
import { actions } from "./_index";

class Item extends Component {
  constructor(props) {
    super(props);
  }
  render() {
    const { val, onMove } = this.props;
    return (
      <li>
        {val.id}+{val.type}+{val.text}
        <span
          onClick={() => onMove(val.id)}
          style={{ marginLeft: "50px", color: "red", cursor: "pointer" }}
        >
          删除
        </span>
      </li>
    );
  }
}
const mapDispatchToProps = (dispatch, ownProps) => {
  //   console.log(ownProps);
  const { id } = ownProps.val;
  //   console.log(id);
  return {
    onMove: () => dispatch(actions.del("删除", id)),
  };
  // 冒号之前的就是我们定义的事件方法名
  // 同样是挂到Props之上
};
export default connect(null, mapDispatchToProps)(Item);
